home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
afloat.zip
/
FLOAT2.C
< prev
next >
Wrap
Text File
|
1988-03-16
|
1KB
|
34 lines
/* float2.c -- sample program showing the use of float.lib and
tinylib.lib; code turns out to be more than 10 times smaller
than comparable program using the standard library's printf
and usual (double-precision) floating point math, and is
about 5-6 times faster; note also that tinylib has clock(),
which, as an ANSI C function should have been included with
Turbo C, but wasn't */
#include "float.h"
#include "tinylib.h"
main()
{
char string [80];
int i;
long mark;
float f, increment = .0001, time_passed, eighteen_point_five = 18.5;
putstr ("enter float: ");
gets (string);
atoflt (string, &f);
mark = clock();
for (i = 0; i < 10000; i++)
fadd (&f, &increment, &f);
ltof (clock() - mark, &time_passed);
fdivide (&time_passed, &eighteen_point_five, &time_passed);
ftoa (&time_passed, string, 4);
putstr ("time in seconds for 10000 loops: ");
putstr (string);
ftoa (&f, string, 6);
putstr ("\n\rresult: ");
putstr (string);
}